package com.pic4493.adapter;

import java.util.HashMap;
import java.util.List;

import com.pic4493.app.R;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdpList_ShareChooser extends ArrayAdapter<HashMap<String, Object>>
{
   private List<HashMap<String, Object>> mChooserList;
   private Context mContext;
   private int mResource = R.layout.comm_module_chooser_list_item;

   public AdpList_ShareChooser(Context context, List<HashMap<String, Object>> chooserList)
   {
	  super(context, 0, chooserList);
	  mChooserList = chooserList;
	  mContext = context;
   }

   @Override
   public View getView(int position, View convertView, ViewGroup parent)
   {
	  LayoutInflater inflater = LayoutInflater.from(mContext);
	  View view = inflater.inflate(mResource, null);

	  ImageView imgAppIcon = (ImageView) view.findViewById(R.id.imgIcon);
	  TextView tvAppLabel = (TextView) view.findViewById(R.id.tvLabel);

	  HashMap<String, Object> share = null;
	  if (mChooserList.size() > position)
	  {
		 share = mChooserList.get(position);
		 if (share != null)
		 {
			imgAppIcon.setImageDrawable((Drawable) share.get("AppIcon"));
			tvAppLabel.setText((CharSequence) share.get("AppLabel"));
		 }
	  }
	  return view;
   }
}
